package com.itshizhan.bottomnavigationviewdemo

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.google.android.material.bottomnavigation.BottomNavigationItemView
import com.google.android.material.bottomnavigation.BottomNavigationView
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        setTv("首页")
        // BottomNavigationView.OnNavigationItemSelectedListener {
        //
        // }
        bottom_nav_bar.setOnNavigationItemSelectedListener {
            when (it.itemId) {
                R.id.home -> {
                    setTv("首页")
                    true
                }
                R.id.photos -> {
                    setTv("相册")
                    true
                }
                R.id.mine -> {
                    setTv("我的")
                    true
                }
                else -> false
            }
        }

    }

    private fun setTv(s: String) {
        setTitle(s)
        tv.text = s
    }
}